<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const s1 = new Set();
        console.log(s1.size);

        const s2 = new Set(['a','b']);
        console.log(s2.size);

        //数组去重
        const s3 = new Set(['a','b','a','b']);
        console.log(s3.size);
        const ary1 = [...s3];
        console.log(ary1);

        //实例方法
        const s4 = new Set();
        //添加值
        s4.add('a').add('b');
        console.log(s4.size);
        //删除值 删除不存在的返回false
        s4.delete('a');
        const r1 = s4.delete('c');
        console.log(s4.size);
        console.log(r1);
        //判断是否是set数据结构中的成员
        const r2 = s4.has('a');
        console.log(r2);
        //清空set数据结构中的值
        s4.clear();
        console.log(s4.size);

        const s5 = new Set(['a','b','c']);
        s5.forEach( value => {
            console.log(value);
        });
    </script>
</body>
</html>